package com.lwj.liwanjia.utils;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.view.activity.personal.SetzfPwdActivity;

/**
 * Created by Administrator on 2017/12/4.
 */

public class ZfPwdDialog extends Dialog implements View.OnClickListener {

    private TextView tvCancle;
    private TextView tvSet;
    private Context context;

    public ZfPwdDialog(@NonNull Context context) {
        super(context, R.style.MyDialog);
        setContentView(R.layout.zf_dialog);
        this.context = context;
        initView();
    }

    private void initView() {
        Window window = getWindow();
        window.setGravity(Gravity.CENTER);
        window.setWindowAnimations(R.style.dialog_animation);
        WindowManager.LayoutParams params = window.getAttributes();
        setCanceledOnTouchOutside(false);
        params.width = params.WRAP_CONTENT;
        params.height = params.WRAP_CONTENT;
        window.setAttributes(params);
        tvCancle = (TextView) findViewById(R.id.tv_cancle);
        tvSet = (TextView) findViewById(R.id.tv_set);
        tvCancle.setOnClickListener(this);
        tvSet.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_cancle:
                dismiss();
                break;
            case R.id.tv_set:
                context.startActivity(new Intent(context, SetzfPwdActivity.class));
                dismiss();
                break;
        }
    }
}
